<?php

/*
  | --------------------------------------------------------------------------------------------------
  | <nova_ordem_de_servico>
  |
  | Desenvolvedor:	Eduardo Sirangelo
  | E-mail:		sirangelos@ibest.com.br
  | Descrição:
  |	-
  | Quality is Everyting
  | --------------------------------------------------------------------------------------------------
 */
?>

<script type='text/javascript' src='<?=base_url()?>/public/js/autocompleta/jquery.autocomplete.min.js'></script>
<link rel="stylesheet" type="text/css" href="<?=base_url()?>/public/js/autocompleta/jquery.autocomplete.css" />

<script src="<?=base_url()?>public/js/caixa/nova_os.js"></script>

<section class="grid_12">
        
    <div class="block-border">
        
        <?
        $attributes = array('class' => 'block-content form', 'id' => 'formOS');
        echo form_open('/caixa/insert_os/',$attributes);

        ?>
        
            <h1>Nova OS</h1>
            
            <div class="columns">

                <div>

                    <div class="columns">

                        <p class="colx3-left">
                            <label for="data">Data</label>
                            <input type="text" name="data" id="data" value="<?=$date_now?>" class="full-width" setDate="true"/>
                        </p>

                        <p class="colx3-center">
                            <label for="id_cliente">Cód. Cliente</label>
                            <input type="text" name="id_cliente" id="id_cliente" value="" class="full-width"/>                        
                        </p>

                        <p class="colx3-right">
                            <label for="nome_cliente">Nome Cliente</label>
                            <input type="text" name="nome_cliente" id="nome_cliente" value="" class="full-width"/>
                        </p>


                    </div>
                    
                    <div class="tabs-content">
			    
                        <ul class="mini-tabs no-margin js-tabs same-height">
                            <li class="current"><a href="#tab-se">Serviços</a></li>
                            <li><a href="#tab-pr">Produtos</a></li>
                        </ul>

                        <div id="tab-se">

                            <div class="no-margin">

                                <table class="table" id="table_s" cellspacing="0" width="100%">

                                    <thead>
                                        <tr>
                                                <th class="black-cell"><span class="loading"></span></th>
                                                <th scope="col" style="width: 10%">Início</th>
                                                <th scope="col" style="width: 10%">Fim</th>
                                                <th scope="col" style="width: 10%">Cód.</th>
                                                <th scope="col" style="width: 35%">Profissional</th>
                                                <th scope="col" style="width: 20%">Serviço</th>
                                                <th scope="col" class="table-actions" style="width: 15%">Vl. Total</th>
                                        </tr>
                                    </thead>

                                    <tbody>
                                        <?
                                        for($i=1;$i <= 4;$i++) {
                                        if($i == 4) {
                                            $class = " valor";
                                        } else {
                                            $class = "";
                                        } 
                                        ?>
                                        <tr>  
                                                <td class="td_grid"></td>
                                                <td class="td_grid"><input type="text" id="hora_ini_<?=$i?>" name="hora_ini_<?=$i?>" class="grid" setHour="true"/></td>
                                                <td class="td_grid"><input type="text" id="hora_fim_<?=$i?>" name="hora_fim_<?=$i?>" class="grid" setHour="true"/></td>
                                                <td class="td_grid"><input type="text" id="id_profissional_<?=$i?>" name="id_profissional_<?=$i?>" label="<?=$i?>" class="grid search_profissional" setNumbers10="true"/></td>
                                                <td class="td_grid"><input type="text" id="profissional_<?=$i?>" name="profissional_<?=$i?>" class="grid"/></td>
                                                <td class="td_grid">
                                                    <select id="id_servico_<?=$i?>" name="id_servico_<?=$i?>" label="<?=$i?>" class="grid set_servico">
                                                        <option value="">1º. Profissional</option>
                                                    </select>
                                                </td>
                                                <td class="td_grid"><input type="text" id="valor_<?=$i?>" name="valor_<?=$i?>" class="grid vl_total_servico <?=$class?>" setMoney="true"/></td>
                                        </tr>
                                        <?
                                        }
                                        ?>
                                    </tbody>

                                </table>
                                
                                <div class="block-footer">

                                </div>

                            </div>

                        </div>

                        <div id="tab-pr">

                            <div class="no-margin">

                                <table class="table" id="table_p" cellspacing="0" width="100%">

                                    <thead>
                                        <tr>
                                            <th class="black-cell"><span class="loading"></span></th>
                                            <th scope="col" style="width: 20%">Vendedor</th>
                                            <th scope="col" style="width: 10%">Cód.</th>
                                            <th scope="col" style="width: 30%">Produto</th>
                                            <th scope="col" style="width: 10%">Qtde.</th>
                                            <th scope="col" style="width: 15%">Vl. Unitário</th>
                                            <th scope="col" style="width: 15%">Vl. Total</th>
                                        </tr>
                                    </thead>

                                    <tbody>
                                        <?
                                        for($j=1;$j <= 4;$j++) {
                                        if($j == 4) {
                                            $class = " valorP";
                                        } else {
                                            $class = "";
                                        } 
                                        ?>
                                        <tr>    
                                            <td class="td_grid">&nbsp;</td>
                                            <td class="td_grid">
                                                <select id="id_vendedor_<?=$j?>" name="id_vendedor_<?=$j?>" class="grid">
                                                    <option value="">Selecione...</option>
                                                    <?
                                                    foreach($query->result() as $row) {
                                                        ?>
                                                        <option value="<?=$row->id_profissional?>"><?=$row->nome_profissional?></option>
                                                        <?
                                                    }
                                                    ?>
                                                </select>
                                            </td>
                                            <td class="td_grid"><input type="text" id="id_produto_<?=$j?>" name="id_produto_<?=$j?>" label="<?=$j?>" class="grid search_produto_by_id" setNumbers10="true"/></td>
                                            <td class="td_grid"><input type="text" id="produto_<?=$j?>" name="produto_<?=$j?>" label="<?=$j?>" class="grid search_produto_by_name"/></td>
                                            <td class="td_grid"><input type="text" id="qtde_<?=$j?>" name="qtde_<?=$j?>" label="<?=$j?>" class="grid search_servico refresh_line_produto" setNumbers10="true"/></td>
                                            <td class="td_grid"><input type="text" id="vl_unitario_<?=$j?>" name="vl_unitario_<?=$j?>" label="<?=$j?>" class="grid" setMoney="true"/></td>
                                            <td class="td_grid"><input type="text" id="vl_total_<?=$j?>" name="vl_total_<?=$j?>" label="<?=$j?>" class="grid vl_total_produto <?=$class?>" setMoney="true" readonly/></td>
                                        </tr>
                                        <?
                                        }
                                        ?>
                                    </tbody>

                                </table>

                                <div class="block-footer">

                                </div>

                            </div>

                        </div>

                    <BR/>

                    <div class="columns">

                        <fieldset>
                            <legend>Valores</legend>
 
                            <div class="colx3-left">
                                <label for="vl_servico">Serviços</label>
                                <input type="text" name="vl_servico" id="vl_servico" value="" class="full-width margin-bottom_5" setMoney="true"/>
                                <label for="vl_produtos">Produtos</label>
                                <input type="text" name="vl_produtos" id="vl_produtos" value="" class="full-width margin-bottom_5" setMoney="true"/>
                            </div>

                            <div class="colx3-center">     
                                <label for="vl_total">Total</label>
                                <input type="text" name="vl_total" id="vl_total" value="" class="full-width" setMoney="true" readonly="true"/>
                            </div>

                            <div class="colx3-right">    
                                <label for="vl_desconto">Desconto</label>
                                <input type="text" name="vl_desconto" id="vl_desconto" value="" class="full-width margin-bottom_5" setMoney="true"/>
                                <label for="vl_troco">Troco</label>
                                <input type="text" name="vl_troco" id="vl_troco" value="" class="full-width margin-bottom_5" setMoney="true" readonly="true"/>
                                <label for="vl_pago">Pago</label>
                                <input type="text" name="vl_pago" id="vl_pago" value="" class="full-width margin-bottom_5" setMoney="true"/>
                            </div>

                        </fieldset>

                    </div>

                </div>

            </div>
            <BR/>
            <fieldset class="grey-bg no-margin">
                    <legend>Salve seu trabalho</legend>

                    <input type="hidden" id="s_count" name="s_count" value="4"/>
                    <input type="hidden" id="p_count" name="p_count" value="4"/>
                           
                    <p class="input-with-button">
                        <button type="submit" class="float-right">Gerar OS</button>
                    </p>
            </fieldset>
            
        </form>
    
    </div>
    
</section>